﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAO
{
     public class CameraDAO
    {
         CameraDBEntities db = new CameraDBEntities();
         public List<Camera> GetListAll()
         {
             return db.Cameras.Where(x=>x.camStatus== true).ToList();
         }
         public List<Camera> GetListTop10()
         {
             return db.Cameras.Where(x => x.camStatus == true).Take(10).ToList();
         }
         public Camera GetById(int id)
         {
             return db.Cameras.Where(x => x.camId == id && x.camStatus == true).SingleOrDefault();
         }

         public List<Camera> GetListSearch(string tukhoa)
         {
             List<Camera> listkq = new List<Camera>();
             listkq = db.Cameras.Where(x => x.camStatus == true).ToList();
             listkq = listkq.FindAll(

                 delegate(Camera math)
                 {
                     if (Utils.ConvertToUnSign(math.camNames.ToLower()).Contains(tukhoa))
                         return true;
                     else
                         return false;
                 }
             );
             return listkq;
         }

    }
}
